package gui;
import java.awt.Button;
import java.awt.Checkbox;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.List;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ButtonGroup;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.SwingUtilities;
/**
 * investigation
 */
public class investigation {

    public  investigation() {
        SwingUtilities.invokeLater(()->{
            JFrame f = new JFrame();
             
			f.setVisible(true);
			f.setSize(400,400);
			f.setLocationRelativeTo(null);
			f.setTitle("个人信息");
			
			Container con = f.getContentPane();
            con.setLayout(null);
			con.setLayout(new GridLayout(6,1));
            // f.setLayout(null);

            //title
        JPanel pan = new JPanel();
        JLabel title = new JLabel("个人信息调查表");
        title.setBounds(150, 50, 100, 20);
        pan.add(title);
        con.add(pan);


            //content
            JPanel pan1 = new JPanel( );
            JLabel surname = new JLabel("姓名");
            surname.setBounds(50, 100, 40, 20);
            TextField identity = new TextField(10);
            identity.setBounds(90, 100, 100,20);

            JLabel sex = new JLabel("性别");
            sex.setBounds(230, 100, 40, 20);
            ButtonGroup groupsex = new ButtonGroup();
            JRadioButton man = new JRadioButton("男", true);
            man.setBounds(270, 100, 60, 20);
            JRadioButton woman = new JRadioButton("女");
            woman.setBounds(330, 100, 60, 20);
            groupsex.add(man);
            groupsex.add(woman);
            pan1.add(surname);pan1.add(identity);
            pan1.add(sex);pan1.add(man);
            pan1.add(woman);
            con.add(pan1);



            JPanel pan2 = new JPanel();
            JLabel age = new JLabel("年龄");
            age.setBounds(50, 150, 40, 20);
            TextField currentage = new TextField("20",4);
            currentage.setBounds(90, 150, 50, 20);
            JLabel district = new JLabel("籍贯");
            district.setBounds(230, 150, 40, 20);
            String[] items = {"北京", "上海", "深圳"};
            JComboBox<String> comboBox = new JComboBox<>(items);
            comboBox.setBounds(270, 150, 60, 20);
            pan2.add(age);
            pan2.add(currentage);
            pan2.add(district);
            pan2.add(comboBox);
            con.add(pan2);



            JPanel pan3 = new JPanel();
            JLabel hobby = new JLabel("爱好");
            Checkbox read = new Checkbox("读书");
            Checkbox surfing = new Checkbox("上网");
            Checkbox gym = new Checkbox("体育活动");
            pan3.add(hobby);pan3.add(read);pan3.add(surfing);pan3.add(gym);
            con.add(pan3);


            JPanel pan4 = new JPanel();
            JLabel likeweb = new JLabel("喜欢的网站");
            // List website = new List(4,false);
            List website = new List();//没有参数时默认为显示4行，不能选择多个
            website.add("新浪");
            website.add("腾讯");
            website.add("网易");
            website.add("淘宝");
            website.add("淘宝1");
            website.add("淘宝2");
            website.add("淘宝3");
            website.add("淘宝4");
            pan4.add(likeweb);
            pan4.add(website);
            con.add(pan4);



            JPanel pan5 = new JPanel();
            Button ok = new Button("确认");
            ok.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                   
                }
            });
            Button cancel = new Button("取消");
            cancel.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                   
                }
            });
            Button exit = new Button("退出");
            exit.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                   f.dispose();
                }
            });
            pan5.add(ok);pan5.add(cancel);pan5.add(exit);
            con.add(pan5);
        });
        

    }
}